//
//  UIImage+FTX.h
//  FTXClient
//
//  Created by Lei Perry on 6/21/13.
//  Copyright (c) 2013 BitRice. All rights reserved.
//

@interface UIImage (EV)
+( UIImage *)ev_imageFromColor:(UIColor*)color;
- (UIImage *)ev_imageTintedWithColor:(UIColor *)color;
- (UIImage *)ev_imageTintedWithColor:(UIColor *)color fraction:(CGFloat)fraction;

- (UIImage *)ev_scaleToSize:(CGSize)size;
- (UIImage *)ev_scaleProportionalToSize:(CGSize)size;

- (UIImage *)ev_convertToTransparentImage;

- (UIImage *)ev_imageAtRect:(CGRect)rect;
- (UIImage *)ev_imageByScalingProportionallyToMinimumSize:(CGSize)targetSize;
- (UIImage *)ev_imageByScalingProportionallyToSize:(CGSize)targetSize;
- (UIImage *)ev_imageByScalingToSize:(CGSize)targetSize;
- (UIImage *)ev_imageRotatedByRadians:(CGFloat)radians;
- (UIImage *)ev_imageRotatedByDegrees:(CGFloat)degrees;

- (UIImage *)ev_fixOrientation;

// 兼容系统版本的resizableImageWithCapInsets:函数
// 低于IOS5则只有capInsets.left capInsets.top生效
- (UIImage *)ev_resizableImageWithCapInsets_x:(UIEdgeInsets)capInsets;

// 相当于原来IOS5之前的stretchableImageWithLeftCapWidth:topCapHeight:
+ (UIImage *)ev_resizeableImageNamed:(NSString *)name
                          capLeft:(CGFloat)left
                           capTop:(CGFloat)top;

// 支持不对称图片的自动拉伸, 低于IOS5则只有capInsets.left capInsets.top生效
// 推荐使用这个API
+ (UIImage *)ev_resizeableImageNamed:(NSString *)name
                        capInsets:(UIEdgeInsets)capInsets;

// 上下左右完全对称的图片自动拉伸
+ (UIImage *)ev_resizeableImageNamed:(NSString *)name;

- (UIImage *)ev_boxblurImageWithBlur:(CGFloat)blur;
/**
 *压缩图片方法
 */
-(UIImage*)ev_compressdImage;
-(NSData*)ev_compressdData;

/**
 *	@brief	Create a partially displayed image
 *
 *	@param 	percentage 	This defines the part to be displayed as original
 *	@param 	vertical 	If YES, the image is displayed bottom to top; otherwise left to right
 *	@param 	grayscaleRest 	If YES, the non-displaye part are in grayscale; otherwise in transparent
 *
 *	@return	A generated UIImage instance
 */
- (UIImage *)ev_partialImageWithPercentage:(float)percentage vertical:(BOOL)vertical grayscaleRest:(BOOL)grayscaleRest;

- (UIImage *)ev_grayscaleImage;

/**模糊效果*/
- (UIImage *)ev_applyLightEffect;
- (UIImage *)ev_applyExtraLightEffect;
- (UIImage *)ev_applyDarkEffect;
- (UIImage *)ev_applyTintEffectWithColor:(UIColor *)tintColor;

- (UIImage *)ev_applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
+ (CGImageRef)ev_CGImageRotatedByAngle:(CGImageRef)imgRef angle:(CGFloat)angle;
-(UIImage*)ev_imageByRotatingImage:(UIImage*)initImage fromImageOrientation:(UIImageOrientation)orientation;

/*
 * 根据图片的大小 得到图片上传时压缩到的大小
 */
+ (CGFloat)ev_caculateUploadImageFileSize:(CGSize)imageSize;

/*
 改变图片尺寸(内存使用大大低于 UIGraphicsBeginImageContext)
 */
+ (UIImage *)ev_resizeImageFromJPEGData:(NSData *)jpegData maxValue:(CGFloat)max;

- (UIImage *)ev_imageWithSize:(CGSize)size radius:(int)radius;
@end
